//
//  BaseIMNet.m
//  SportSocial
//
//  Created by yull on 14/12/23.
//  Copyright (c) 2014年 yull. All rights reserved.
//

#import "BaseIMNet.h"

@implementation BaseIMNet

+ (instancetype)shareInstance
{
    static BaseIMNet *baseNet = nil;
    static dispatch_once_t predictate;
    dispatch_once(&predictate, ^{
        baseNet = [[BaseIMNet alloc] init];
    });
    return baseNet;
}

- (instancetype)init
{
    if (self = [super init]) {
        self.arrayPid = [NSMutableArray arrayWithObject:[NSNumber numberWithInteger:IM_ERROR_PID]];
    }
    return self;
}

- (void)handlePacketWithPid:(NSInteger)pid recvData:(NSData *)recvData
{
    if (pid == IM_ERROR_PID) {
        NSLog(@"IM错误消息");
    }
}

- (NSInteger)chatMsgIsSending:(UInt64)dbId
{
    NSInteger index = -1;
    for (NSInteger i=0;i<self.msgArray.count;i++){
        ChatBaseMsg *baseMsg = [self.msgArray objectAtIndex:i];
        if (baseMsg.dbId == dbId) {
            index = i;
            break;
        }
    }
    return index;
}

- (void)dealloc
{
    [self.msgArray removeAllObjects];
    self.msgArray = nil;
}
@end
